package com.xjtu.backend.result;

import lombok.*;

@Getter
@ToString
@NoArgsConstructor
@AllArgsConstructor
public enum ResponseEnum implements IResponseEnum<Integer, String, ResponseEnum> {
    SUCCESS(200, "success"),
    UNAUTHORIZED(401, "unauthorized"),
    FORBIDDEN(403, "forbidden"),
    NOT_FOUND(404, "not_found"),
    FAILD(500, "faild"),
    PARAM_MISS(501, "param_miss"),
    MAINTENANCE(-500, "maintenance"),
    // code 可以自己规范一下，不同值的范围
    SAVE_ERROR(-202, "新增失败"),
    UPDATE_ERROR(-203, "修改失败"),
    DELETE_ERROR(-204, "删除失败"),
    QUERY_ERROR(-205, "查询失败"),
    PERMISSION_ERROR(-206, "无权限操作"),
    PARAM_ERROR(-207, "非法参数");

    private Integer code;
    private String message;


    @Override
    public ResponseEnum get() {
        return this;
    }

    @Override
    public Integer code() {
        return this.code;
    }

    @Override
    public String message() {
        return this.message;
    }
}
